/******************************************************************************

  File Name     : rtsp_client_api.h
  Version       : Initial Draft
  Author        : tongzhilin
  Created       : 2020/8/6
  Last Modified :
  Description   : rtsp_client_api
  Function List :
  History       :
  1.Date        : 2020/10/27
    Author      : tongzhilin
    Modification: Created file

******************************************************************************/

#pragma once

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

#define RTSP_CHN_NUM_MAX                (16)
#define RTSP_CLIENT_THREAD_MAX          (4)

#define RTSP_ERRCODE_INNER_ERR          (-1)
#define RTSP_ERRCODE_INPUT_PARAM_ERR    (-2)
#define RTSP_ERRCODE_INPUT_PARAM_NULL   (-3)

#define RTSP_OK                         (0)
#define RTSP_FAIL                       (-1)
#define RTSP_TRUE                       (1)
#define RTSP_FALSE                      (0)

#define RTSP_DATA_HEAD_LEN              (2048)

#define RTSP_CHN_FRAME_NUM_MAX          (70)

typedef enum 
{
    RTSP_STATUS_NONE,
    RTSP_STATUS_NO_EXIST,
    RTSP_STATUS_RUN,
    RTSP_STATUS_STOP,
}RTSP_CLIENT_STATUS_E;

typedef struct 
{
    void*   m_pVideoCb;
    void *  m_pAudioCb;
    int     rtsp_type;      //1 udp, 0 or other tcp
}RTSP_CLEINT_INIT_INFO_S;

typedef enum
{
    RTSP_VIDEO_ENCODE_H264,
    RTSP_VIDEO_ENCODE_H265,
}RTSP_VIDEO_ENCODE_E;

typedef enum
{
    BL_AVFRM_TYPE_A = 0,
    BL_AVFRM_TYPE_I = 1,
    BL_AVFRM_TYPE_P = 2,
    BL_AVFRM_TYPE_B = 3,
    BL_AVFRM_TYPE_JPEG = 4,
}BL_AVFRM_TYPE_E;

typedef enum 
{
    NAL_ALL,
    NAL_SLICE = 1,
    NAL_DPA,
    NAL_DPB,
    NAL_DPC,
    NAL_IDR_SLICE,
    NAL_SEI,
    NAL_SPS,
    NAL_PPS,
    NAL_AUD,
    NAL_END_SEQUENCE,
    NAL_END_STREAM,
    NAL_FILLER_DATA,
    NAL_SPS_EXT,
    // for H265
    NAL_IDR_W_RADL = 19,
    // non-VCL
    NAL_UNIT_VPS = 32,      // 32
    NAL_UNIT_SPS,           // 33
    NAL_UNIT_PPS,           // 34
    NAL_UNIT_AUD,           // 35
    NAL_UNIT_EOS,           // 36
    NAL_UNIT_EOB,           // 37
    NAL_UNIT_FILLER_DATA,   // 38
    NAL_UNIT_PREFIX_SEI,    // 39
    NAL_UNIT_SUFFIX_SEI,    // 40
}BL_NAL_TYPE_E;

typedef struct
{
    RTSP_VIDEO_ENCODE_E m_eEncodeType;
    BL_AVFRM_TYPE_E     m_eFrameType;
    char*               m_pdata;
    int                 m_s32DataSize;
    unsigned long long  m_u64Pts;
}BL_FRAME_DATA_S;

typedef struct
{
    //int                 m_eEncodeType;
    int                 m_s32DataSize;
    char*               m_pdata;
    unsigned long long  m_u64Pts;
}BL_AUDIO_DATA_S;

typedef void(*RTSP_VIDEO_CB_HANDLE)(int _s32Chn, BL_FRAME_DATA_S* _pstFrameData);
typedef void(*RTSP_AUDIO_CB_HANDLE)(int _s32Chn, BL_AUDIO_DATA_S* _pstAudioData);

int rtsp_init(RTSP_CLEINT_INIT_INFO_S _stInput);
int rtsp_deinit();
int rtsp_open_url(int _s32Chn,const char* _pUrl);
int rtsp_close_url(int _s32Chn);

#ifdef __cplusplus
}
#endif  /* __cplusplus */

